package com.example.demo.collections;

import java.util.UUID;

public class Test {

	public static void main(String[] args) {
		// testHashMap();
		// testArrayList();
		// testStack();
		testTreeMap();
	}

	
	
	public static void testArrayList() {
		MyArrayList<Integer> myArrayList = new MyArrayList<>();
		for (int i = 0; i < 100; i++) {
			myArrayList.add(i);
		}
		System.out.println(myArrayList);
		myArrayList.clear();
		System.out.println(myArrayList);
	}

	public static void testHashMap() {
		MyHashMap<String, String> myHashMap = new MyHashMap<>(1 << 20, 0.75f);
		int size = 1800000;
		long start = System.currentTimeMillis();
		for (int i = 0; i < size; i++) {
			String s = UUID.randomUUID().toString();
			myHashMap.put(s, s);
		}
		long end = System.currentTimeMillis();
		System.out.println(myHashMap.entrySet());
		System.out.println("HashMap插入" + size + " 条数据所需时间：" + (end - start) + " 毫秒");
	}

	public static void testStack() {
		MyStack myStack = new MyStack(100);
		for (int i = 0; i < 100; i++) {
			myStack.push(i);
		}

		for (int i = 0; i < 100; i++) {
			System.out.println(myStack.pop());
		}
	}
	
	public static void testTreeMap() {
		MyTreeMap<String, String> myTreeMap = new MyTreeMap<String, String>();
		int size = 100;
		long start = System.currentTimeMillis();
		for (int i = 0; i < size; i++) {
			String s = UUID.randomUUID().toString();
			myTreeMap.put(s, s);
		}
		long end = System.currentTimeMillis();
		System.out.println(myTreeMap.entrySet());
		System.out.println("TreeMap插入" + size + " 条数据所需时间：" + (end - start) + " 毫秒");
	}
	
}